package action.agent;

import org.apache.struts2.ServletActionContext;

import service.interf.IAgentBaseConfig;
import action.common.MyBaseAction;

import com.opensymphony.xwork2.ModelDriven;

import dao.pojo.AgentBaseConfig;

/**
 * 代理商配置
 * 
 * @author Administrator
 * 
 */
public class AgentBaseConfigAction extends MyBaseAction<AgentBaseConfig>
		implements ModelDriven<AgentBaseConfig> {

	private static final long serialVersionUID = 1L;
	private IAgentBaseConfig iAgentBaseConfig;

	public void setiAgentBaseConfig(IAgentBaseConfig iAgentBaseConfig) {
		this.iAgentBaseConfig = iAgentBaseConfig;
	}

	public AgentBaseConfigAction() {
		super(AgentBaseConfig.class);
	}

	public AgentBaseConfig getModel() {
		return model;
	}

	/**
	 * 初始化列表
	 */
	public void getlist() {
		String r;
		try {
			r = iAgentBaseConfig.findByProperty("AgentBaseConfig", "*", "json",
					true, null, null, null, null, model.getPage(), model
							.getRows());
		} catch (Exception e) {
			r = errorHandle.handleErr(e);
		}
		servletHandle.writeToClient(ServletActionContext.getResponse(), r);
	}

	/**
	 * 获取当前代理商基数
	 */
	public void getbyid() {
		String r;
		try {
			r = iAgentBaseConfig.getById();
		} catch (Exception e) {
			r = errorHandle.handleErr(e);
		}
		servletHandle.writeToClient1(ServletActionContext.getResponse(), r);
	}

	/**
	 * 添加
	 */
	public void add() {
		String r;
		try {
			r = iAgentBaseConfig.add(model);
		} catch (Exception e) {
			r = errorHandle.handleErr(e);
		}
		servletHandle.writeToClient1(ServletActionContext.getResponse(), r);
	}

	/**
	 * 修改
	 */
	public void edit() {
		String r;
		try {
			r = iAgentBaseConfig.edit(model);
		} catch (Exception e) {
			r = errorHandle.handleErr(e);
		}
		servletHandle.writeToClient1(ServletActionContext.getResponse(), r);
	}

}
